package cn.jiedh.app.meiweidk.buried;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.JsonObject;
import cn.jiedh.app.meiweidk.Utils.tool.SPUtils;

import org.xutils.db.annotation.Column;
import org.xutils.db.annotation.Table;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @name：埋点数据实体类
 * @author：司马林
 * @phone：18423134135
 * @createTime：2017/10/27
 */
@Table(name = "BuriedBean")
public class BuriedBean implements Parcelable{
    /**
     * @param action 用户行为标识,主要有：download（下载）,downloaded（下载成功）,activate（激活）,registry（注册）,login（登录）,
     * query（查询）,click（点击）,apply（申请）,stay（停留）,share（分享）,(可以自定义标识)
     * @param actName 用户触发事件名称
     * @param actTime 事件触发时间,如2017-10-31 10:05:22
     * @param targetType 操作对象类型，有0按钮(默认)，产品 1,banner 2,广告 3, 攻略 4,活动 5, 信用卡 6,常见问题 7,问卷调查8,其他9，app自有界面10（如首页）
     * @param targetId 操作对象ID
     * @param targetName 操作对象名称
     * @param currentPage 当前页面名称或者地址 (拿不到对象ID时，传当前页面地址或名称，如首页，如果能拿到对象ID不需传)
     * @param isReact 是否甲方(与甲方交互, 比如在甲方注册, 进入甲方页面) ，进入甲方产品时传是，否则为否
     * @param isLogin 是否登录，是和否，当前事件操作时的登录状态
     * @param stayTime 页面停留时间，当事件为stay时，需要通过客户端计算某个页面的停留时间，并上传
     * @param queryCondition 查询条件 查询条件以Json组装，当事件为query时，客户端组装查询条件上传
     * @param shareChannel 分享渠道，如QQ,微信，微博，当事件为share时上传分享的渠道
     * @param verifyCode 验证码
     * @param inviteChannel 邀请渠道，如QQ,微信，微博，当事件为invite时上传邀请的渠道
     * @param loanMoney 金额
     * @param loanTerm 期限
     * @param loanSort 排序方式（智能排序...）
     * @param interestRate 利率
     * @param loanType 贷款类型
     * @param otherData 额外的数据
     */
    @Column(isId = true,name = "id" ,autoGen = true)
    private int id;
    @Column(name = "action")
    private String action;
    @Column(name = "actName")
    private String actName;
    @Column(name = "actTime")
    private String actTime;
    @Column(name = "targetType")
    private String targetType;
    @Column(name = "targetId")
    private String targetId;
    @Column(name = "targetName")
    private String targetName;
    @Column(name = "currentPage")
    private String currentPage;
    @Column(name = "isReact")
    private String isReact;
    @Column(name = "isLogin")
    private String isLogin;
    @Column(name = "stayTime")
    private String stayTime;
    @Column(name = "queryCondition")
    private String queryCondition;
    @Column(name = "shareChannel")
    private String shareChannel;
    @Column(name = "verifyCode")
    private String verifyCode;
    @Column(name = "inviteChannel")
    private String inviteChannel;
    @Column(name = "loanMoney")
    private String loanMoney;
    @Column(name = "loanTerm")
    private String loanTerm;
    @Column(name = "loanSort")
    private String loanSort;
    @Column(name = "interestRate")
    private String interestRate;
    @Column(name = "loanType")
    private String loanType;
    @Column(name = "otherData")
    private JsonObject otherData;

    public BuriedBean(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        this.actTime = sdf.format(new Date());
    }

    public BuriedBean(String action, String actName, String targetType, String targetId, String targetName, String currentPage,
                      String isReact, String stayTime, String queryCondition, String shareChannel, String verifyCode, String inviteChannel,
                      String loanMoney, String loanTerm, String loanSort, String interestRate, String loanType) {
        this.action = action;
        this.actName = actName;
        this.targetType = targetType;
        this.targetId = targetId;
        this.targetName = targetName;
        this.currentPage = currentPage;
        this.isReact = isReact;
        this.stayTime = stayTime;
        this.queryCondition = queryCondition;
        this.shareChannel = shareChannel;
        this.verifyCode = verifyCode;
        this.inviteChannel = inviteChannel;
        this.loanMoney = loanMoney;
        this.loanTerm = loanTerm;
        this.loanSort = loanSort;
        this.interestRate = interestRate;
        this.loanType = loanType;

        this.isLogin = SPUtils.getIsLogin() + "";

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        this.actTime = sdf.format(new Date());
    }

    protected BuriedBean(Parcel in) {
        id = in.readInt();
        action = in.readString();
        actName = in.readString();
        actTime = in.readString();
        targetType = in.readString();
        targetId = in.readString();
        targetName = in.readString();
        currentPage = in.readString();
        isReact = in.readString();
        isLogin = in.readString();
        stayTime = in.readString();
        queryCondition = in.readString();
        shareChannel = in.readString();
        verifyCode = in.readString();
        inviteChannel = in.readString();
        loanMoney = in.readString();
        loanTerm = in.readString();
        loanSort = in.readString();
        interestRate = in.readString();
        loanType = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(id);
        dest.writeString(action);
        dest.writeString(actName);
        dest.writeString(actTime);
        dest.writeString(targetType);
        dest.writeString(targetId);
        dest.writeString(targetName);
        dest.writeString(currentPage);
        dest.writeString(isReact);
        dest.writeString(isLogin);
        dest.writeString(stayTime);
        dest.writeString(queryCondition);
        dest.writeString(shareChannel);
        dest.writeString(verifyCode);
        dest.writeString(inviteChannel);
        dest.writeString(loanMoney);
        dest.writeString(loanTerm);
        dest.writeString(loanSort);
        dest.writeString(interestRate);
        dest.writeString(loanType);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<BuriedBean> CREATOR = new Creator<BuriedBean>() {
        @Override
        public BuriedBean createFromParcel(Parcel in) {
            return new BuriedBean(in);
        }

        @Override
        public BuriedBean[] newArray(int size) {
            return new BuriedBean[size];
        }
    };

    public JsonObject getOtherData() {
        return otherData;
    }

    public void setOtherData(JsonObject otherData) {
        this.otherData = otherData;
    }

    public String getAction() {
        return action;
    }

    public String getActName() {
        return actName;
    }

    public String getActTime() {
        return actTime;
    }

    public String getTargetType() {
        return targetType;
    }

    public String getTargetId() {
        return targetId;
    }

    public String getTargetName() {
        return targetName;
    }

    public String getCurrentPage() {
        return currentPage;
    }

    public String getIsReact() {
        return isReact;
    }

    public String getIsLogin() {
        return isLogin;
    }

    public String getStayTime() {
        return stayTime;
    }

    public String getQueryCondition() {
        return queryCondition;
    }

    public String getShareChannel() {
        return shareChannel;
    }

    public String getVerifyCode() {
        return verifyCode;
    }

    public String getInviteChannel() {
        return inviteChannel;
    }

    public String getLoanMoney() {
        return loanMoney;
    }

    public String getLoanTerm() {
        return loanTerm;
    }

    public String getLoanSort() {
        return loanSort;
    }

    public String getInterestRate() {
        return interestRate;
    }

    public String getLoanType() {
        return loanType;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public void setActName(String actName) {
        this.actName = actName;
    }

    public void setActTime(String actTime) {
        this.actTime = actTime;
    }

    public void setTargetType(String targetType) {
        this.targetType = targetType;
    }

    public void setTargetId(String targetId) {
        this.targetId = targetId;
    }

    public void setTargetName(String targetName) {
        this.targetName = targetName;
    }

    public void setCurrentPage(String currentPage) {
        this.currentPage = currentPage;
    }

    public void setIsReact(String isReact) {
        this.isReact = isReact;
    }

    public void setIsLogin(String isLogin) {
        this.isLogin = isLogin;
    }

    public void setStayTime(String stayTime) {
        this.stayTime = stayTime;
    }

    public void setQueryCondition(String queryCondition) {
        this.queryCondition = queryCondition;
    }

    public void setShareChannel(String shareChannel) {
        this.shareChannel = shareChannel;
    }

    public void setVerifyCode(String verifyCode) {
        this.verifyCode = verifyCode;
    }

    public void setInviteChannel(String inviteChannel) {
        this.inviteChannel = inviteChannel;
    }

    public void setLoanMoney(String loanMoney) {
        this.loanMoney = loanMoney;
    }

    public void setLoanTerm(String loanTerm) {
        this.loanTerm = loanTerm;
    }

    public void setLoanSort(String loanSort) {
        this.loanSort = loanSort;
    }

    public void setInterestRate(String interestRate) {
        this.interestRate = interestRate;
    }

    public void setLoanType(String loanType) {
        this.loanType = loanType;
    }

    @Override
    public String toString() {
        return "BuriedBean{" +
                "id=" + id +
                ", action='" + action + '\'' +
                ", actName='" + actName + '\'' +
                ", actTime='" + actTime + '\'' +
                ", targetType='" + targetType + '\'' +
                ", targetId='" + targetId + '\'' +
                ", targetName='" + targetName + '\'' +
                ", currentPage='" + currentPage + '\'' +
                ", isReact='" + isReact + '\'' +
                ", isLogin='" + isLogin + '\'' +
                ", stayTime='" + stayTime + '\'' +
                ", queryCondition='" + queryCondition + '\'' +
                ", shareChannel='" + shareChannel + '\'' +
                ", verifyCode='" + verifyCode + '\'' +
                ", inviteChannel='" + inviteChannel + '\'' +
                ", loanMoney='" + loanMoney + '\'' +
                ", loanTerm='" + loanTerm + '\'' +
                ", loanSort='" + loanSort + '\'' +
                ", interestRate='" + interestRate + '\'' +
                ", loanType='" + loanType + '\'' +
                ", otherData=" + otherData +
                '}';
    }
}